#include <iostream>
#include <stdio.h>

class Base
{
	public:
		void function_1()
		{
			printf("function_1...\n");
		}

		virtual void function_2()
		{
			printf("function_2...\n");
		}
};

int main(int argc, char ** argv)
{
	Base base;

	printf("size %ld\n", sizeof(class Base));	// 8 , 有 virtual 之后为 8， 除掉 virtual ， 为 1

	base.function_1();
	base.function_2();
}

#if 0

对象调用时，虚与普通函数没有区别。

int main(int argc, char ** argv)
{
    11a9:	f3 0f 1e fa          	endbr64 
    11ad:	55                   	push   %rbp
    11ae:	48 89 e5             	mov    %rsp,%rbp
    11b1:	48 83 ec 20          	sub    $0x20,%rsp
    11b5:	89 7d ec             	mov    %edi,-0x14(%rbp)
    11b8:	48 89 75 e0          	mov    %rsi,-0x20(%rbp)
    11bc:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    11c3:	00 00 
    11c5:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    11c9:	31 c0                	xor    %eax,%eax
	Base base;
    11cb:	48 8d 05 ae 2b 00 00 	lea    0x2bae(%rip),%rax        # 3d80 <_ZTV4Base+0x10>
    11d2:	48 89 45 f0          	mov    %rax,-0x10(%rbp)

	base.function_1();
    11d6:	48 8d 45 f0          	lea    -0x10(%rbp),%rax
    11da:	48 89 c7             	mov    %rax,%rdi
    11dd:	e8 8e 00 00 00       	callq  1270 <_ZN4Base10function_1Ev>
	base.function_2();
    11e2:	48 8d 45 f0          	lea    -0x10(%rbp),%rax
    11e6:	48 89 c7             	mov    %rax,%rdi
    11e9:	e8 a2 00 00 00       	callq  1290 <_ZN4Base10function_2Ev>
}
    11ee:	b8 00 00 00 00       	mov    $0x0,%eax
    11f3:	48 8b 55 f8          	mov    -0x8(%rbp),%rdx
    11f7:	64 48 33 14 25 28 00 	xor    %fs:0x28,%rdx
    11fe:	00 00 
    1200:	74 05                	je     1207 <main+0x5e>
    1202:	e8 89 fe ff ff       	callq  1090 <__stack_chk_fail@plt>
    1207:	c9                   	leaveq 
    1208:	c3                   	retq   


#endif
